package gsfordservlet.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import gsfordservlet.service.GsfordEventManager;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Map;
import java.util.HashMap;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *  
 * @author Kyungbaek Kim <kyungbaekkim@gmail.com>
 * @version 2012.0202 (YYYY.MMDD)
 * @since 1.6 (Java Version)
 */
public class ReviewNotificationController implements Controller {

    protected final Log logger = LogFactory.getLog(getClass());

    private GsfordEventManager eventManager;

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String now = (new java.util.Date()).toString();
        logger.info("Review notification view with " + now);

        Map<String, Object> myModel = new HashMap<String, Object>();
        myModel.put("now", now);
        myModel.put("events", this.eventManager.getGsfordEvents() );

        return new ModelAndView("review_notification", "model", myModel);
    }

    public void setEventManager(GsfordEventManager gem) {
        this.eventManager = gem;
    }

}
